
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.CharBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel;
import java.nio.channels.OverlappingFileLockException;
import java.nio.charset.Charset;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;

import com.sun.org.apache.xml.internal.resolver.helpers.Debug;

/**
 * @author mainak
 */
public class JettyMain {

    private final static Log LOG = LogFactory.getLog(JettyMain.class);

    /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {

  

        Server server = new Server();
        Connector connector = new SelectChannelConnector();
        
        connector.setPort(2040);
        server.setConnectors(new Connector[] { connector });

        HandlerList all = new HandlerList();        
        Context context = new Context(all, "/dev");
        context.addServlet(new ServletHolder(new stcClustering()), "/stc");
        context.addServlet(new ServletHolder(new lingoClustering()), "/lingo");
        context.addServlet(new ServletHolder(new debugApp()), "/debug");
        
        
        
        ResourceHandler rh = new ResourceHandler();
    
        rh.setResourceBase("/home/sidjain/workspace1/Http Api/src");

                
        server.setHandler(all);
        all.addHandler(rh);
        
        
        
        server.setHandler(all);
        

        LOG.info("starting server...");
        server.start();
        server.join();

    }

    private static String usage() {
        return "java -jar listener.jar <pid-file> <pid>";
    }
}
